import {applyMiddleware, compose, createStore} from 'redux';
import reducer from './reducers';
import createSagaMiddleware from 'redux-saga';

export default function configureStore() {
    const sagaMiddleware = createSagaMiddleware();
    const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
    const store = createStore(reducer, composeEnhancers(
        applyMiddleware(sagaMiddleware)
    ));
    if (process.env.NODE_ENV !== 'production' && module.hot) {
        module.hot.accept('./reducers', () => store.replaceReducer(reducer))
    }
    return store;
}
